#include <inctypes.h>
#include <incctrls.h>

/*********************************************************************************
* 
* spinlock_init - 自旋锁初始化
* 
* DESCRIPTION
*/

void spinlock_init
    (
    spinlock_t * lock
    )
    {
    ARCH_SPINLOCK_INIT (lock);
    return;
    }

/*********************************************************************************
* 
* spinlock_lock - 自旋锁上锁
* 
* DESCRIPTION
*/

void spinlock_lock 
    (
    spinlock_t * lock
    )
    {
    ARCH_SPINLOCK_LOCK (lock);
    return;
    }    

/*********************************************************************************
* 
* spinlock_unlock - 自旋锁解锁
* 
* DESCRIPTION
*/

void spinlock_unlock 
    (
    spinlock_t * lock
    )
    {
    ARCH_SPINLOCK_UNLOCK (lock);
    return;
    }

/*********************************************************************************
* 
* spinlock_saveflg_cli - 带中断控制的自旋锁上锁
* 
* DESCRIPTION
*/

void spinlock_saveflg_cli 
    (
    spinlock_t * lock, 
    cpuflg_t *   cpuflg
    )
    {
    cpuflg_t tmpcpsr;

    ARCH_SPINLOCK_SAVEFLG_CLI_1 (tmpcpsr);

    *cpuflg = tmpcpsr;    /* 把原来的 CPSR 寄存器 的值保存到 cpuflg 指向的内存单元中 */

    ARCH_SPINLOCK_SAVEFLG_CLI_2 (lock);

    return;
    }

/*********************************************************************************
* 
* spinunlock_restflg_sti - 带中断控制的自旋锁解锁
* 
* DESCRIPTION
*/

void spinunlock_restflg_sti
    (
    spinlock_t * lock, 
    cpuflg_t *   cpuflg
    )
    {
    ARCH_SPINUNLOCK_RESTFLG_STI_1 (lock);
    ARCH_SPINUNLOCK_RESTFLG_STI_2 (cpuflg);
    return;
    }
